<%@ page import="com.company.app.login.login.LoginBean" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="javax.script.ScriptEngineManager" %>
<%@ page import="javax.script.ScriptEngine" %>
<%--
  Created by IntelliJ IDEA.
  User: bill
  Date: 2010-7-7
  Time: 10:12:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/core/transition.jsp" %>
<%
    //test request.getParameter
    String userName = request.getParameter("userName");
    System.out.println("userName = " + userName);
    _transition_init();
    _transition_begin(false);
    try {

        //test _dao_getString
        String a = _dao_getString("select 123 from dual");
        System.out.println("_dao_getString = " + a);

        //test _dao_getObject
        Map map = new HashMap();
        map.put("USER_NAME", "userName");
        LoginBean b = (LoginBean) _dao_getObject("select 123 as USER_NAME from DUAL", "com.company.app.login.login.LoginBean", map);
        System.out.println("_dao_getObject = " + b);

        //test _dao_getObject
        LoginBean b2 = (LoginBean) _dao_getObject("select 123 as USER_NAME, 789 as TEST from DUAL", "com.company.app.login.login.LoginBean");
        System.out.println("_dao_getObject = " + b2);

        //test _dao_getObject
        LoginBean b3 = (LoginBean) _dao_getObject("select 123 as USER_NAME,456 as PASS_WORD, 789 as TEST from DUAL", "com.company.app.login.login.LoginBean");
        System.out.println("_dao_getObject = " + b3);

        //test _dao_getObject
        LoginBean b4 = (LoginBean) _dao_getObject("select 123 as USER_NAME,456 as PASS_WORD, 789 as TEST, 101 as ID from DUAL", "com.company.app.login.login.LoginBean");
        System.out.println("_dao_getObject = " + b4);

        //test _dao_getList
        List l1 = _dao_getList("select 123 as USER_NAME,456 as PASS_WORD, 789 as TEST, 101 as ID from staff_info where rownum <100", "com.company.app.login.login.LoginBean");
        System.out.println("_dao_getList = " + l1);

        //test _dao_getObject
        Map b5 = _dao_getObject("select 123 as USER_NAME,456 as PASS_WORD, 789 as TEST, 101 as ID from staff_info where rownum <100");
        System.out.println("_dao_getList = " + b5);

//        this._dao_execute("insert into test_transition values('123')");
//        this._dao_execute("insert into test_transition values('456')");

        //String s1 = _dao_getString("select 789 fom dual");
    } catch (Exception e) {
        e.printStackTrace();
        _transition_rollback();
    }
    _transition_commit();

%>

<jsp:useBean id="loginInfo" class="com.company.app.login.login.LoginBean" scope="request"/>
<jsp:include page="/app/util/util.jsp">
    <jsp:param name="beanID" value="loginInfo"/>
    <jsp:param name="className" value="com.company.app.login.login.LoginBean"/>
    <jsp:param name="sql" value="select 123 as USER_NAME from dual"/>
</jsp:include>
<%
    loginInfo = (LoginBean) request.getAttribute("loginInfo");
%>
<%=loginInfo%>

<jsp:useBean id="loginInfoMap" class="java.util.HashMap" scope="request"/>
<jsp:include page="/app/util/util.jsp">
    <jsp:param name="beanID" value="loginInfoMap"/>
    <jsp:param name="className" value=""/>
    <jsp:param name="sql" value="select 123 as USER_NAME from dual"/>
</jsp:include>
<%
    loginInfoMap = (HashMap) request.getAttribute("loginInfoMap");
%>
<%=loginInfoMap.get("USER_NAME")%>
${requestScope.loginInfoMap.USER_NAME}

<%
    ScriptEngineManager _sem = new ScriptEngineManager();
    ScriptEngine e = _sem.getEngineByName("JavaScript");

    this._transition_init();
    this._transition_begin(true);
    e.put("t", this);
    //this._db_getConnection();
    String script = "for (var i in t.dependants){ println(i);}";
    e.eval(script);
    this._transition_commit();
%>

